#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int rst[100086] = {};
int ipt[100086];

int main(int argc, char const *argv[])
{
    int n = 0;
    while (cin >> ipt[++n]) {}
    n--;

    int ct = 0;
    for (int i = 1; i <= n; i++)
    {
        int *p = upper_bound(rst, rst + n + 1, ipt[i], greater<int>());
        *p = ipt[i];
    }
    for (int j = 0; j <= n; j++)
    {
        if (rst[j] == 0)
        {
            break;
        }
        ct++;
    }
    cout << ct << endl;
    
    for (int i = 0; i < 100086; i++)
    {
        rst[i] = 500000;
    }

    for (int i = 1; i <= n; i++)
    {
        int *p = lower_bound(rst, rst + n + 1, ipt[i]);
        *p = ipt[i];
    }
    
    ct = 0;
    for (int i = 0; i <= n; i++)
    {
        if (rst[i] == 500000)
        {
            break;
        }
        ct++;
    }

    cout << ct;

    return 0;
}
